<template>
	<view class="page">
		<div class="myUnit">
			<div class="titleDiv">
				<uni-section title="订单信息" type="line"></uni-section>
			</div>
			<div class="myText">
				<div>生产单号：</div>
				<div>{{form.orderNo||'-'}}</div>
			</div>
			<div class="myText">
				<div>商品名称：</div>
				<div>{{form.productName||'-'}}</div>
			</div>
			<div class="myText">
				<div>订单状态：</div>
				<div>{{form.orderStatusDesc||'-'}}</div>
			</div>
			<div class="myText">
				<div>业务员：</div>
				<div>{{form.createBy||'-'}}</div>
			</div>
			<div class="myText">
				<div>订单数量：</div>
				<div>{{form.quantity||'-'}}</div>
			</div>
			<div class="myText">
				<div>商品规格：</div>
				<div>{{form.skuDescCn||'-'}}</div>
			</div>
			<div class="myText">
				<div>备注：</div>
				<div>{{form.orderStatusDesc||'-'}}</div>
			</div>
		</div>
		<div class="myBtn">
			<u-button v-if="flag==0" type='primary' text="报工" @click="confirm()" throttleTime='1000'></u-button>
			<u-button v-else type='primary' text="入库" @click="confirm()" throttleTime='1000'></u-button>
		</div>
	</view>
</template>

<script>
	import {
		getOrder,storeProduceOrder
	} from "@/api/orderMng/index.js"
	export default {
		data() {
			return {
				flag:0,
				form: {}
			}
		},
		onLoad(e) {
			this.flag=e.flag
			this.load(218)
		},
		methods: {
			load(id) {
				uni.showLoading()
				getOrder(id).then(res => {
					this.form = res.data
				})
			},
			confirm(){
				if(this.flag==0){
					uni.navigateTo({
						url: '/pages/orderMng/reportWork?id=' + this.form.id+'&flowId='+this.form.flowId
					})
				}else{
					let req={
						id: this.form.id,
					}
					uni.showLoading({
						mask:true
					})
					storeProduceOrder(req).then(res => {
						uni.showToast({
							title: '入库成功',
							success() {
								setTimeout(e => {
									uni.navigateBack()
								}, 500)
							}
						})
					})
				}
			}
		}
	}
</script>
<style scoped lang="scss">
	.titleDiv {
		display: flex;
		justify-content: space-between;
	}

	.aBtn {
		color: #0275a1 !important;
	}

	.myText div:nth-child(1) {
		min-width: 80px;
	}

	.myText2 div:nth-child(1) {
		min-width: 80px;
	}

	.unitDiv {
		padding-bottom: 10px;
		border-bottom: 2px dashed #f3f4f5;
	}


	.myText2 {
		width: 50%;
		display: inline-block;
	}

	.myText2 div {
		display: inline-block;
	}

	.myUnit .myText2:nth-child(even) {
		text-align: right;
	}
</style>